//1290. 二进制链表转整数
//思路：从高位开始每次*2再加后一项，这样高位相当于一次一次被乘

struct ListNode {
    int val;
    struct ListNode *next;
};
int getDecimalValue(struct ListNode* head){
    int num = 0;
    while(head)
    {
        num = num * 2 + head->val;
        head = head->next;
    }
    return num;
}